import api from '../../api';
import _ from 'lodash';
import { message } from 'antd';
import { isZiGuanEvir } from '../../utils/commonFunc';
export default {
  namespace: 'isAccountConfiguredM',
  state: {
    msg: '该组合您还未配置外部指令通道，请先至“组合定义”页面完成配置。',
  },
  effects: {
    // 根据组合ID，判断该组合是否进行了指令配置
    *queryIsAccountConfigured({ payload, callback }, { call, put, select }) {
      let isZIGUAN = false;
      let res;
      if (payload.etfType) {
        // 判断当前环境是不是资管
        let temp = isZiGuanEvir();
        if (!!temp) isZIGUAN = true;
        delete payload.etfType;
      }
      if (isZIGUAN) {
        res = yield call(api.isAccountConfiguredZG, payload);
      } else {
        res = yield call(api.isAccountConfigured, payload);
      }
      if (res && res.code == 0) {
        callback({
          result: true,
          msg: '',
        });
      } else {
        callback({
          result: false,
          msg: '该组合您还未配置外部指令通道，请先至“组合定义”页面完成配置。',
        });
      }
    },
  },

  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
